package company.maestro;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.hardware.SensorManager;

public class DatabaseHelper extends SQLiteOpenHelper {

	private static final String DATABASE_NAME="db";
	public static final String TITLE="title";
	public static final String VALUE="value";
	
	public DatabaseHelper(Context context) {
		super(context, DATABASE_NAME, null, 1);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase arg0) {
		arg0.execSQL("CREATE TABLE constants (_id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, value REAL);");
		ContentValues cv = new ContentValues();
		
		cv.put(TITLE, "Gravity, Death Star I");
		cv.put(VALUE,SensorManager.GRAVITY_DEATH_STAR_I);
		arg0.insert("constants",TITLE,cv);

	}

	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
		android.util.Log.w("Constants", "Upgrading database, which will destroy all old data");
		arg0.execSQL("DROP TABLE IF EXISTS contants");
		onCreate(arg0);

	}

}
